package com.zhuyuan.security.exception;

import com.zhuyuan.core.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


/**
 * @description: 安全异常捕获处理
 * @author: 张琳凯
 * @date: 2025/2/11 11:45
 **/
@Slf4j
@RestControllerAdvice
public class SecurityExceptionHandler {


    /**
     * 无权限异常处理
     *
     * @param e the e
     */
    @ExceptionHandler(AccessDeniedException.class)
    public Result handleAccessDeniedException(AccessDeniedException e) {

        log.error("无权限异常==>exception:{}", e.getMessage());
        return Result.fail("无权限访问！");
    }


}
